package FlyGame;

import javax.swing.*;
import java.awt.*;
import java.sql.ResultSet;

public class RankPanel extends JPanel {
    DbUtil dbUtil;
    Object[] params;

    public RankPanel() {
        dbUtil = new DbUtil();
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        FlyPicture.RankTwo.paintIcon(this,g,0,0);
        g.setColor(Color.black);
        g.setFont(new Font("微软雅黑",Font.BOLD,15));
        params = new Object[]{};

        ResultSet resultSet = dbUtil.doQuery("select score from 2_com.score order by score DESC", params);
        int[] result = dbUtil.paintResult(resultSet);
        g.drawString("分数 ：",56,95);
        g.drawString(String.valueOf(result[0]),120,95);

        g.drawString("分数 ：",56,145);
        g.drawString(String.valueOf(result[1]),120,145);

        g.drawString("分数 ：",56,195);
        g.drawString(String.valueOf(result[2]),120,195);

        g.drawString("分数 ：",56,245);
        g.drawString(String.valueOf(result[3]),120,245);

        g.drawString("分数 ：",56,290);
        g.drawString(String.valueOf(result[4]),120,290);
    }
}